package com.maxd.respository.sysRole;

import com.maxd.model.SysMenu;
import com.maxd.model.SysRoleMenu;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.Repository;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;


public interface SysRoleMenuRepository extends Repository<SysRoleMenu, Long> {

    /**
     * 根据角色ID，获取菜单ID列表
     */
    @Query(value = "select menu_id from sys_role_menu where role_id = :roleId",nativeQuery = true)
    List<Long> queryMenuIdList(Long roleId);

    /**
     * 根据角色ID
     */
    @Transactional
    @Modifying
    @Query(value = "delete from sys_role_menu where role_id=:roleId",nativeQuery = true)
    int deleteBatch(Long roleId);

}